#include <cstdio>

int main() {
    const int MAX = 10;
    long long a, b, x, y;
    int sum_a = 0, sum_b = 0;
    scanf("%lld%lld%lld%lld", &a, &x, &b, &y);

    while (a != 0) {
        if (a % 10 == x) sum_a = sum_a * 10 + x;
        a /= 10;
    }
    while (b != 0) {
        if (b % 10 == y) sum_b = sum_b * 10 + y;
        b /= 10;
    }

    printf("%d\n", sum_a+sum_b);

}